package br.com.absolutech.study.chapter5.p206ex3;

public class Propagate {

    public static void main(String[] args) {

	try {
	    System.out.println(reverse(""));
	} catch (Exception e) {
	    e.printStackTrace();
	} finally {
	    System.out.println("passed through finally from reverse");
	}

    }

    static String reverse(String text) throws Exception {
	if (text.length() == 0) {
	    throw new Exception();
	    //	    throw new IndexOutOfBoundsException("string vazia"); unchecked exception
	}
	String reverseStr = "";
	for (int i = text.length() - 1; i >= 0; --i) {
	    reverseStr += text.charAt(i);
	}
	return reverseStr;
    }

}
